import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import Shop from '../views/Shop.vue'
import Myufun from '../views/Myufun.vue'
import Myaddress from '../views/Myaddress.vue'
import Myorder from '../views/Myorder.vue'
import Detail from '../views/Detail.vue'
import Register from '../views/Register.vue'
import Shopmain from '../views/Shopmain.vue'
import Cart from '../views/Cart.vue'
Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home
  },
  {
    path: '/shop',
    name: 'Shop',
    component: Shop
  },
  {
    path: '/myufun',
    name: 'Myufun',
    component: Myufun
  },
  {
    path: '/myaddress',
    name: 'Myaddress',
    component: Myaddress
  },
  {
    path: '/myorder',
    name: 'Myorder',
    component: Myorder
  },
  {
    path: '/detail',
    name: 'Detail',
    component: Detail
  },
  {
    path: '/register',
    name: 'Register',
    component: Register
  },
  {
    path: '/shopmain',
    name: 'Shopmain',
    component: Shopmain
  },
  {
    path:'/detail',
    name:"Detail",
    component:Detail
  },
  {
    path:'/cart',
    name:'Cart',
    component:Cart
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

const routerPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return routerPush.call(this, location).catch(error => {
    console.log("路由添加重复"+error)
  })
}
export default router
